home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9034 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  40 lines

  1. Path: holly.ACNS.ColoState.EDU!not-for-mail
  2. From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: No struct in C++!!?
  5. Date: 27 Feb 1996 21:07:09 -0700
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4h0kdd$lb2@holly.ACNS.ColoState.EDU>
  8. References: <1996Feb14.151620.5532@queens-belfast.ac.uk> <00001a81+0000a7ee@msn.com>
  9. NNTP-Posting-Host: holly.acns.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Bing Xiao (bxiao@msn.com) wrote:
  13. : a beginners question: I found in different C++ books examples of C++ programms
  14. : which contain type declarations and definitions in the main() programm - for
  15. : example a struct  - as in C.
  16. : My question is, whether this is a contradiction 
  17. : to the paradigm of C++. Shouldn't be everything in a C++ programm
  18. : either classes, objects or the interaction between objects?
  19. : So is it bad C++ style, to use functions or data outside from
  20. : classes (objects)?
  21.  
  22. We've had this discussion in my data structures class.  It isn't always appropriate
  23. to encapsulate data when it isn't necessary.  In C++, the struct is little more
  24. than a class with default public access.  You can still have member functions
  25. and data, there is just no access control.  I've found that when dealing with
  26. simple records, it is considerably easier (and more efficient) to use structs
  27. than to use classes where they would be overkill.
  28.  
  29.  
  30. // ------------ BEGIN SIGNATURE ---------------
  31. #include <iostream.h>
  32. void main()
  33. {
  34.   cout<<"\aName:\tCorby S. Hudnall\n";
  35.   cout<<"School:\tColorado State University\n";
  36.   cout<<"EMail\tcorbyh@holly.colostate.edu\n";
  37.   cout<<"URL\thttp://holly.colostate.edu/~corbyh/\n";
  38. }
  39. // ------------- END SIGNATURE ----------------
  40.